import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/hj_page/mine_business/mine_setting/bing_phone_page.dart';
import 'package:xvideos/hj_page/mine_business/mine_setting/mine_scan_login_page.dart';
import 'package:xvideos/hj_page/mine_business/mine_utils.dart';
import 'package:xvideos/hj_utils/permission_util.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';

class MineFindAccountPage extends StatelessWidget {
  static const routeName = '/mine/find_account';
  late final dataSource = [
    {'title': '手机号找回', 'ontap': () => Get.toNamed(BindPhonePage.routeName, arguments: PhonePageType.find)},
    {
      'title': '凭证找回',
      'ontap': () async {
        if (await PermissionUtil.checkCameraPermission()) {
          Get.toNamed(MineScanLoginPage.routeName);
        }
      }
    },
    {'title': '联系客服', 'ontap': () => MineUtils.goCSPage()}
  ];
  MineFindAccountPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(elevation: 0, title: Text('找回账号')),
      body: Padding(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              padding: EdgeInsets.symmetric(horizontal: 16),
              decoration: BoxDecoration(
                color: Colors.white.withOpacity(.05),
                borderRadius: BorderRadius.circular(8),
              ),
              child: ListView.separated(
                physics: NeverScrollableScrollPhysics(),
                itemCount: dataSource.length,
                shrinkWrap: true,
                separatorBuilder: (_, __) => Divider(
                  height: 0.5,
                  color: Colors.white.withOpacity(.1),
                ),
                itemBuilder: (BuildContext context, int index) {
                  final data = dataSource[index];
                  return GestureDetector(
                    behavior: HitTestBehavior.translucent,
                    onTap: data['ontap'] as Function()?,
                    child: Column(
                      children: [
                        16.sizeBoxH,
                        Row(
                          children: [
                            Text(
                              (data['title'] ?? '').toString(),
                              style: TextStyle(fontSize: 14, color: Colors.white.withOpacity(0.9)),
                            ),
                            Spacer(),
                            Icon(
                              Icons.arrow_forward_ios_rounded,
                              size: 14,
                              color: Color(0xFFDCDCDC),
                            )
                          ],
                        ),
                        16.sizeBoxH,
                      ],
                    ),
                  );
                },
              ),
            )
          ],
        ),
      ),
    );
  }
}
